package Exists;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Hash_K {

    public static void main(String[] args) {

        HashMap<Integer, String> res = new HashMap<>();

      res.put(1,"张三" );
      res.put(2,"李四" );
      res.put(3,"王五" );

        Set<Integer> integers = res.keySet();

        for (Integer integer : res.keySet()) {
            System.out.println( res.get(integer));
        }


        System.out.println("========================");
        Set<Map.Entry<Integer, String>> entries = res.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {

            Integer key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key +"--------"+value);

        }

        //获取键为1的值
        System.out.println("获取键为1的值"+res.get(1));

        //获取键为10的值

        System.out.println("获取键10的值"+res.get(10));

        //判断集合中是否存在10 key
        System.out.println("判断集合中是否存在10 key"+res.containsKey(10));

        //删除键为1的集合,
        System.out.println(res.remove(1));
        System.out.println(res);


    }

}
